<?php

class DevelopAction extends CommonAction {

	// 条形码管理
	public function barcode(){
		if (!C('barcode')){
			exit('未开启条形码，无需配置');
		}
		$model		= D('Admin');
		$this->list	= $model->getBarcode();
		$this->info	= array(
			'country'	=> '国家编号',
			'size_no'	=> '尺码编号',
			'color_no'	=> '颜色编号',
			'class_no'	=> '类别编号',
			'product_no'=> '产品编号',
			'comp_no'	=> '公司',
			'serial_no'	=> '流水号'
		);
		$this->display();
	}

	//保存条形码业务规则
	public function saveBarcode(){
		if (C('barcode')) {
			$Model = D('Admin');
			$Model->addConfigBarcode($_POST);
			redirect('barcode',2,'保存成功，2秒后跳转');
		}else{
			exit('未开启条形码，无需配置');
		}
	}

	// 字典管理
	public function dd(){
		$this->dd = M('Dd')->order('id asc')->select();
		$this->display();
	}
	
	// 开发配置下菜单管理
    public function node(){
    	if ($_GET['id']>0) {
    		$where = ' (parent_id='.$_GET['id'].')';
    	}else{
    		$where = 'group_id=0 and level=1';
    	}
    	$this->node = M('Node')->where($where)->order('sort asc')->select();
    	$this->display();
    }
    
    // 开发配置下编辑节点信息
    public function editnode(){
    	$rs = M('Node')->find($_GET['id']);
    	if ($rs['parent_id'] && $temp = M('Node')->find($rs['parent_id'])) {
    		$rs['parent_title'] = $temp['title'];
    		unset($temp);
    	}
    	if ($rs['group_id'] && $temp = M('Node')->find($rs['group_id'])) {
    		$rs['group_title'] = $temp['title'];
    	}
    	$this->rs =$rs;
    	$this->display();
    }
    
    // 开发配置下保存节点信息
    public function saveNode(){
    	$model = M('Node');
    	$model->create($_POST);
    	$model->save();
    	header("location:".__URL__."/node");
    }
    
    // 开发配置下删除节点信息
    public function deletenode(){
    	M('Node')->delete($_GET['id']);
    	header("location:".__URL__."/node");
    }
	
	
}